package game.tycoon.sosial;
import android.content.Context;
import android.media.MediaPlayer;

public class GameSound {

		private static MediaPlayer menumusic;
		private static MediaPlayer gamemusic;
		private static MediaPlayer tabrakan;
		private static MediaPlayer shout;
		public static boolean isMusicPlayed;

		public static void startMenuMusic(Context context) {
//			menumusic = MediaPlayer.create(context, R.raw.musik_menu);
//			menumusic.setLooping(true);
//			menumusic.start();
//			WorldSetting.soundenabled = true;
//			isMusicPlayed = true;
		}
		
		public static void stopMenuMusic() {
			if(menumusic!=null) {
				menumusic.release();
				WorldSetting.soundenabled = false;
				isMusicPlayed = false;
			}
		}

		public static void startGameMusic(Context context) {
//			gamemusic = MediaPlayer.create(context, R.raw.musik_game);
//			gamemusic.setLooping(true);
//			gamemusic.start();
//			WorldSetting.soundenabled = true;
//			isMusicPlayed = true;
		}

		public static void stopGameMusic() {
			if(gamemusic!=null) {
				gamemusic.release();
				WorldSetting.soundenabled = false;
				isMusicPlayed = false;
			}
		}
		
		public static void startTabrakan(Context context) {
			//jika sound dienable dan bunyi tabrakan yang lain udah selesai baru bisa distart lagi
//			if(tabrakan==null) {//jika null
//				tabrakan = MediaPlayer.create(context, R.raw.kelereng_hit);
//			}
//			if (WorldSetting.soundenabled && !tabrakan.isPlaying()) {
//				tabrakan = MediaPlayer.create(context, R.raw.kelereng_hit);
//				tabrakan.start();
//			}
		}
		public static void startShout(Context context, int id) {
			//jika sound dienable dan bunyi tabrakan yang lain udah selesai baru bisa distart lagi
//			if(shout==null) {//jika null
//				if (id==1){
//					shout = MediaPlayer.create(context, R.raw.mangstab);				
//				}
//				else if (id==2){
//					shout = MediaPlayer.create(context, R.raw.pestagundu);				
//				}
//				else if (id==3){
//					shout = MediaPlayer.create(context, R.raw.habisdah);				
//				}
//
//			}
//			if (WorldSetting.soundenabled && !shout.isPlaying()) {
//				if (id==1){
//					shout = MediaPlayer.create(context, R.raw.mangstab);
//					shout.start();			
//				}
//				else if (id==2){
//					shout = MediaPlayer.create(context, R.raw.pestagundu);
//					shout.start();				
//				}
//				else if (id==3){
//					shout = MediaPlayer.create(context, R.raw.habisdah);
//					shout.start();		
//				}
//			}
		}		
		
		public static void changeMusicFromGameToMain(Context context) {
			if(WorldSetting.soundenabled){
				GameSound.stopGameMusic();
				GameSound.startMenuMusic(context);
			}
		}
		
		public static void changeMusicFromMainToGame(Context context) {
			if(WorldSetting.soundenabled){
				GameSound.stopMenuMusic();
				GameSound.startGameMusic(context);
			}
		}

}
